import { createStore, applyMiddleware } from 'redux'
import rootReducer from '../reducers'

import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage/session'
// import storage from 'redux-persist/lib/storage'; //localStorage机制

const storageConfig = {
  key: 'root', // 必须有的
  storage, // 缓存机制
  blacklist: [], // reducer 里持久化的数据,除此外均为不持久化数据
}

const myPersistReducer = persistReducer(storageConfig, rootReducer)
let store = createStore(myPersistReducer)



console.log("inital state:", store.getState())
export const persistor = persistStore(store)
export default store;